package com.ocom.company.dao;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ocom.common.entity.master.EntityMngUserInfo;
import com.ocom.company.vo.GetCompanyListByPhoneVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface IDaoMngUserInfo extends BaseMapper<EntityMngUserInfo> {

    @Select("SELECT m.user_name,m.com_id,m.role,c.com_name,c.logo_url FROM mng_user_info m \n" +
            "LEFT JOIN company_list c ON  m.com_id=c.com_id  WHERE  m.phone=#{phone}")
    public List<GetCompanyListByPhoneVo> GetCompanyListByPhone(String phone);

    @Select({"<script>",
            "select user.* from mng_user_info user",
            "left join mng_account_info acc on user.id=acc.user_id",
            "where ( user.user_name = #{account} or acc.phone= #{account}",
            "or acc.third_openid= #{account}  )  ",
            "<if test='role != null'> and user.role= #{role} </if>",
            "</script>"
    })
    EntityMngUserInfo getUserByNameAndRole(String account, String role);
}
